from PyQt6.QtGui import QDragEnterEvent, QDropEvent
from PyQt6.QtWidgets import QTextEdit, QWidget


class DropTextEdit(QTextEdit):
    def __init__(self, parent=None):
        super().__init__(parent)

    def dragEnterEvent(self, e: QDragEnterEvent):
        e.acceptProposedAction()

    def dropEvent(self, e: QDropEvent):
        for url in e.mimeData().urls():
            file_name = url.toLocalFile()
            self.setText(file_name)
